import { createRouter,createWebHistory } from "vue-router";

const router = createRouter({
    history: createWebHistory(),
    routes:[
        {
            path:'/login',
            name:'login',
            component: () => import('@/views/Login/Login.vue')
        },
        {
            path:'/',
            component: () => import('@/views/Layout/index.vue'),
            name:'layout',
            children:[
                {
                    path:'',
                    name:'home',
                    component:() => import('@/views/Home/index.vue')
                },
                {
                    path:'category/:id',
                    name:'category',
                    component:() => import('@/views/Category/index.vue')
                },
                {
                    path: 'category/sub/:id',
                    name: 'subCategory',
                    component:() => import('@/views/subCategory/index.vue')
                },
                {
                    path: 'detail/:id',
                    name:'detail',
                    component:() => import('@/views/Detail/index.vue')
                },
                {
                    path: 'cartlist',
                    name: 'cartlist',
                    component:() => import('@/views/CartList/index.vue')
                },
                {
                    path: 'checkout',
                    name: 'checkout',
                    component: () => import('@/views/CheckOut/index.vue')
                },
                {
                    path: 'pay',
                    name: 'pay',
                    component: () => import('@/views/Pay/index.vue')
                },
                {
                    path: 'payback',
                    name: 'payback',
                    component: () => import("@/views/Pay/PayBack.vue")
                },
                {
                    path: 'member',
                    name: 'member',
                    component: () => import("@/views/Member/index.vue"),
                    children:[
                        {
                            path: 'order',
                            name: 'order',
                            component: () => import("@/views/Member/components/UserInfo.vue")
                        },
                        {
                            path: '',
                            name: 'info',
                            component: () => import("@/views/Member/components/UserOrder.vue")
                        }
                    ]
                }
            ]
        }
    ],
    scrollBehavior () {
        return {
            top:0
        }
    }
})

export default router